package com.acctrue.zentao.utils;

import java.io.Serializable;

/**
 * @author: 孙炯炯
 * @since: 2023/8/18
 **/

public class ResponseResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private Boolean success;
    private String message;
    private String details;
    private String code;
    private T data;

    public ResponseResult() {
    }

    public ResponseResult(Boolean success, String code, String message) {
        this.success = success;
        this.message = message;
        this.code = code;
    }

    public ResponseResult(String code, T data, Boolean success) {
        this.code = code;
        this.data = data;
        this.success = success;
    }

    public static <T> ResponseResult<T> success() {
        return new ResponseResult(Boolean.TRUE, "200", (String)null);
    }

    public static <T> ResponseResult<T> success(T body) {
        return new ResponseResult("200", body, Boolean.TRUE);
    }

    public ResponseResult<T> withMessage(String message) {
        this.setMessage(message);
        return this;
    }

    public static <T> ResponseResult<T> errorMessage(String message) {
        return new ResponseResult(Boolean.FALSE, "0", message);
    }

    public static <T> ResponseResult<T> error() {
        return new ResponseResult(Boolean.FALSE, "0", (String)null);
    }

    public static <T> ResponseResult<T> error(String code, String msg) {
        return new ResponseResult(Boolean.FALSE, code, msg);
    }

    public Boolean getSuccess() {
        return this.success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getDetails() {
        return this.details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
